package com.sdr.dahuavideo.plugin;

import android.app.Activity;
import android.content.Intent;

import com.sdr.dahuavideo.DahuaMainActivity;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;

/**
 * Created by HeYongFeng on 2016/10/11.
 */
public class DahuaVideoPlugin extends CordovaPlugin {

    private Activity mActivity;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        mActivity = cordova.getActivity();
        if (action.equals("startDahuaVideo")){
            Intent intent = new Intent(mActivity, DahuaMainActivity.class);
            intent.putExtra("ipAddress",args.getString(0));
            intent.putExtra("port",args.getString(1));
            intent.putExtra("userName",args.getString(2));
            intent.putExtra("passWord",args.getString(3));
            mActivity.startActivity(intent);
            return true;
        }
        return false;
    }
}
